﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CSProjectCodeLine
{
    class Program
    {
        static int Main(string[] args)
        {
            int result = 0;
            try
            {
                Console.WriteLine("===============Aladdin Tool================");
                Console.WriteLine("参数:打表配置文件名或打表配置文件所在的目录");
                Console.WriteLine("===========================================");
                if (args.Length == 0)
                {
                    Console.WriteLine("Error:请填写路径参数");
                    Console.ReadKey();
                    result = 1;
                }
                else if (args.Length == 1)
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(args[0]);
                    if (dirInfo == null)
                    {
                        Console.WriteLine("Error:路径有误");
                        Console.ReadKey();
                        result = 1;
                    }
                    else
                    {
                        CodeCounter counter = new CodeCounter();
                        counter.GetProjectResult(dirInfo.FullName);
                        int codenumber = counter.CodeLines;
                        int filenumber = counter.FileNumber;
                        Console.WriteLine("项目中共有cs代码文件" + filenumber + "个");
                        Console.WriteLine("项目中共有代码" + codenumber + "行");
                        Console.ReadKey();
                        result = 0;
                    }
                }
                else
                {
                    Console.WriteLine("Error:参数只支持一个工程路径");
                    Console.ReadKey();
                    result = 1;
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ((Console.ForegroundColor == ConsoleColor.Red) ? ConsoleColor.Green : ConsoleColor.Red);
                Console.WriteLine(ex.ToString());
                Console.ResetColor();
                result = 1;
            }
            return result;
        }
    }
}
